package org.mock.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.mock.entity.QyWechatExternalContact;
import org.mock.mapper.QyWechatExternalContactMapper;
import org.mock.service.QyWechatService;
import org.springframework.stereotype.Service;

/**
 * 服务实现类
 *
 * @author AI
 * @since 2025-05-21
 */
@Service
@AllArgsConstructor
@Slf4j
public class QyWechatServiceImpl implements QyWechatService {

    protected QyWechatExternalContactMapper qyWechatExternalContactMapper;

    @Override
    public String getExternalContactDetail(String externalUserid) {
        QyWechatExternalContact qyWechatExternalContact = qyWechatExternalContactMapper.selectOne(
                new LambdaQueryWrapper<QyWechatExternalContact>()
                        .eq(QyWechatExternalContact::getExternalUserid, externalUserid)
        );
        if (ObjectUtil.isEmpty(qyWechatExternalContact)) {
            log.info("客户不存在！");
            return "客户不存在！";
        }
        return qyWechatExternalContact.getResponse();
    }
}
